import static org.junit.Assert.*;

import java.util.ArrayList;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;

/**
 * 
 */

/**
 * @author user
 *
 */
public class TestTrajet {
	
	Trajet t1;
	Trajet t2;
	Trajet t3;
	Trajet t4;
	Trajet t5;
	Trajet t6;
	Date d1;
	Date d2;
	Date d3;
	Date d4;
	Passager p1;
	Passager p2;
	ArrayList<Passager> passagers;

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
		d1 = new Date(111, 10, 18, 12, 04);
		d2 = new Date(111, 11, 20, 12, 04);
		d3 = new Date(111, 10, 30, 14, 59);
		d4 = new Date(111, 12, 0, 1, 2);
		
		t1 = new Trajet(Villes.NEWYORK, Villes.PARIS, d1, d2);
		t2 = new Trajet(Villes.MARSEILLE, Villes.NICE, d3, d4);
		
		p1 = new Passager("maugard", "matthieu");
		p2 = new Passager("paeta", "suzy");
		
		passagers = new ArrayList<Passager>();
		passagers.add(p1);
		passagers.add(p2);
	}

	/**
	 * Test method for {@link Trajet#getVilleDepart()}.
	 */
	@Test
	public void testGetVilleDepart() {
		assertEquals(Villes.NEWYORK, t1.getVilleDepart());
	}

	/**
	 * Test method for {@link Trajet#getVilleArrivee()}.
	 */
	@Test
	public void testGetVilleArrivee() {
		assertEquals(Villes.NICE, t2.getVilleArrivee());
	}

	/**
	 * Test method for {@link Trajet#getDateDebut()}.
	 */
	@Test
	public void testGetDateDebut() {	
		assertEquals(d1, t1.getDateDebut());
	}

	/**
	 * Test method for {@link Trajet#getDateFin()}.
	 */
	@Test
	public void testGetDateFin() {
		assertEquals(d4, t2.getDateFin());
	}

	/**
	 * Test method for {@link Trajet#getCapaciteCourante()}.
	 */
	@Test
	public void testGetCapaciteCourante() {
		t2.setCapaciteCourante(3);
		assertEquals(3, t2.getCapaciteCourante());
	}

	/**
	 * Test method for {@link Trajet#incrementeCapaciteCourante()}.
	 */
	@Test
	public void testIncrementeCapaciteCourante() {
		t1.setCapaciteCourante(2);
		t1.incrementeCapaciteCourante();
		assertEquals(3, t1.getCapaciteCourante());
		
	}

	/**
	 * Test method for {@link Trajet#getPassagers()}.
	 */
	@Test
	public void testGetPassagers() {
		t1.setPassagers(passagers);		
		assertEquals(passagers, t1.getPassagers());
	}

    /**
     * 
     */
    @Test(expected=NullPointerException.class)
    public void testNullPointerException() {
    	t3 = new Trajet(null, Villes.MARSEILLE, d1, d2);
    	t4 = new Trajet(Villes.NEWYORK, null, d1, d2);
    	t5 = new Trajet(Villes.NICE, Villes.MARSEILLE, null, d1);
    	t6 = new Trajet(Villes.MARSEILLE, Villes.PARIS, d1, null);
    	t2.setPassagers(null);
    	
    }

    /**
     * 
     */
    @Test(expected=IllegalArgumentException.class)
    public void testIllegalArgumentException(){
    	t1.setCapaciteCourante(-2);
    }

}
